package com.example.restatr.Atcivity.GovServiceHotline;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.ViewPager;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.restatr.Adapter.CardAdapter;
import com.example.restatr.Atcivity.Main.MainActivity;
import com.example.restatr.Bean.CardBean;
import com.example.restatr.R;
import com.example.restatr.Tools;
import com.youth.banner.Banner;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class GovServiceHotlineAt extends AppCompatActivity {
    private Toolbar toolbar;
    private TextView barTitle;
    private EditText search;
    private Banner rbt;
    private GridView card;
    public static List<CardBean> cardBeans = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_gov_service_hotline_at );

        toolbar = findViewById( R.id.toolbar );
        barTitle = findViewById( R.id.bar_Title );
        search = findViewById( R.id.search );
        rbt = findViewById( R.id.banner );
        card = findViewById( R.id.card );
        cardBeans.clear();
        Tools.SetBarTitle( toolbar, barTitle, "政府服务热线", search, this,false );
        Tools.SetBanner("/prod-api/api/gov-service-hotline/ad-banner/list", MainActivity.sp.getString( "token", "" ), "data", "imgUrl",
                rbt,this);
        Tools.SetCard( "/prod-api/api/gov-service-hotline/appeal-category/list", MainActivity.sp.getString( "token", "" ),
                "url", "rows", "id", "imgUrl", "name", this, cardBeans, card );

        card.setOnItemClickListener( new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent( GovServiceHotlineAt.this, GovServiceInfoAt.class );
                intent.putExtra( "name", cardBeans.get( position ).getTitle() );
                intent.putExtra( "id", cardBeans.get( position ).getId() );
                startActivity( intent );
            }
        } );
    }
}